-- apper_damage
-- created by panyl
-- 怪物出现时概率造成伤害

return {
    apply = function(prop, baseValue)
        return prop[3];
    end,

    -- 攻击时触发
    trigger = function(who, prop, arg)
        local target = arg[1];

        -- 概率没发生
        if DungeonM.getRandSeed("apper_damage") % 1000 >= prop[3] then
            return false;
        end

        -- 百分比伤害
        local damage = math.modf(target:getHp() * tonumber(prop[2]) / 1000);
        if damage < 1 then
            return false;
        end

        CombatM.doDamage(who, target, damage, 0);

        -- 触发特技发动事件
        EventMgr.fire(event.SPECIAL_SKILL_TRIGGER, { propId = prop[1], pos = arg[2] });

        return true;
    end,

    record = function(target, prop, path)
        return false;
    end
};
